package com.lenovo.nova.util.view;

import java.lang.reflect.Field;
import java.util.Arrays;

import com.lenovo.nova.util.sContext;
import com.lenovo.nova.util.debug.ToastAlertUtil;

import android.view.ViewGroup.LayoutParams;

public class LayoutParamsUtils {

	public static final String topMargin = "topMargin";
	
	public static void executeValue(LayoutParams params, String[] properys,int[] values) {
		if(params == null){
			ToastAlertUtil.alertError("LayoutParams is null", sContext.get());
			return;
		}
		
		for (int i = 0; i < properys.length; i++) {
			try {
				Field field = params.getClass().getField(properys[i]);
				field.setAccessible(true);
				field.set(params, values[i]);
			} catch (Exception e) {
				ToastAlertUtil.alertError(e + " \n" + params + " \n" +
			    Arrays.asList(properys).toString() + "  \n" + 
			    Arrays.asList(values).toString() ,null);
				
				e.printStackTrace();
			} 
		}
	}
}
